package com.ruoyi.web.controller.hk;

import com.ruoyi.hk.domain.HSysRole;
import com.ruoyi.hk.domain.vo.HSysRoleTypeVo;
import com.ruoyi.hk.service.HSysRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/sysRole")
@Api(tags = "角色接口")
public class HSysRoleController {
    @Autowired
    private HSysRoleService HSysRoleService;

    @GetMapping("/getSysRoleByType")
    @ApiOperation("根据类型获取角色列表")
    public ResponseEntity<?> getSysRoleByType(){
        List<HSysRole> HSysRoles = HSysRoleService.getSysRoleByType();
        List<HSysRoleTypeVo> vos = new ArrayList<>();
        HSysRoles.forEach(role -> {
            HSysRoleTypeVo vo = new HSysRoleTypeVo(role.getRoleId(), role.getRoleName());
            vos.add(vo);
        });
        return ResponseEntity.ok(vos);
    }
}
